﻿namespace CheckoutCodeKata
{
    public class SpecialPriceRule
    {
        private string _code;
        private int _quantity;
        private int _price;

        public SpecialPriceRule(string code, int quantity, int price)
        {
            _code = code;
            _price = price;
            _quantity = quantity;
        }

        public int ApplyPriceRule(int quantity, string code, Counter counter)
        {
            int remaining = quantity;
            if (!code.Equals(_code))
            {
                return remaining;
            }

            while (remaining >= _quantity)
            {
                counter.IncrementBy(_price);
                remaining -= quantity;
            }
            return remaining;
        }

    }
}
